package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.HomePageDto;
import edu.suda.xsap.dto.convert.HomePageConvert;

import edu.suda.xsap.entity.HomePage;
import edu.suda.xsap.mapper.HomePageMapper;

import edu.suda.xsap.service.HomePageService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.Month;
import java.time.Year;
import java.util.List;
@Service
public class HomePageServiceImpl implements HomePageService {
    @Autowired
    private HomePageConvert homepageConvert;

    @Autowired
    private HomePageMapper homepageMapper;

    @Override

    public Integer getMemCount(){return homepageMapper.getMemCount();};
    @Override
    public Integer getActiveCount(){return homepageMapper.getActiveCount();};

    @Override
    public List<HomePageDto> getMonthlyCharge(Year year, Month month){

        List<HomePage>  monthlyCharges= homepageMapper.getMonthlyCharge(year, month);
        return homepageConvert.toDtoList(monthlyCharges);
    }
    @Override
    public List<HomePageDto> getCardCount(){
        List<HomePage>  cardCounts = homepageMapper.getCardCount();
        return homepageConvert.toDtoList(cardCounts);
    }

}
